<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>游币比例管理页面</title>
    
    <meta charset="utf-8"/>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" href="gold/css/bootstrap.min.css">
	<link rel="stylesheet" href="gold/css/index.css" />
	<script src="gold/js/jquery.js"></script>
	<script src="gold/js/bootstrap.min.js"></script>
	<style type="text/css">
		#container {
			margin-top: -20px;
			margin-left: 10px;
		}
		td {
			vertical-align: middle !important;
		}
	</style>
	<script type="text/javascript">
		$(function(){
			$("#all").click(function(){
				var all = $("#all").prop("checked");
				if(all){
					$("input[name='opt']").prop("checked",true);
				}else{
					$("input[name='opt']").prop("checked",false);
				}
			});
		});
		function deleteExchange(){
			var v1 = confirm("确认删除吗？");
			if(v1){
				var arr = [];
				$("input[name='opt']").each(function(){
					var choose = $(this).prop("checked");
					if(choose){
						arr.push($(this).val());
					}
				});
				if(arr.length<=0){
					alert("请选择至少一行删除！");
					return;
				}
				//alert(arr);
				location.href="deleteExchange.do?provId="+arr;
			}
		}
	</script>
	

  </head>
  
  <body>
    <div id="container">
		<div class="page-header ">
			<h2>游币换算比例</h2>
		</div>
		<form action="getExchangeByProvId.do" method="post">
			<div class="row">
				<div class="col-xs-4 col-sm-3 " >
					<div class="row">
						<div class="col-xs-8 col-sm-2">
							<span class="btn btn-default">省份</span>
						</div>
						<div class="col-xs-3 col-sm-5">
							<select  class="form-control" name="provId">
								<c:forEach items="${provinceList}" var="province">
									<option value="${province.provId }">${province.provName }</option>
								</c:forEach>
							</select>
						</div>
						<div class="col-xs-6 col-sm-4 ">
							<input type="submit" class="btn btn-primary" id="search" value="查询" />
						</div>
					</div>
				</div>
			</div>
		</form>
		<div class="row">&nbsp;</div>
		<div class="row">
			<div class="col-xs-6 col-sm-4">
				<a class="btn btn-primary" data-toggle="modal"
					data-target="#myModal"> <span class="glyphicon glyphicon-plus"></span>
					新增</a>
				<a class="btn btn-danger" onclick="deleteExchange()"> <span
					class="glyphicon glyphicon-trash"></span> 删除</a>
			</div>
		</div>
		
		<div class="modal fade" id="myModal" tabindex="-1" >
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
							>&times;</button>
						<h4 class="modal-title" id="myModalLabel">添加游币比例</h4>
					</div>
					<div class="modal-body">
						<form action="insertExchange.do" method="post" enctype="multipart/form-data" class="form-horizontal">
							<div class="form-group">
								<label for="exchangeProvId" class="col-sm-2 control-label">省份</label>
								<div class="col-sm-10">
									<select class="form-control" name="exchangeProvId">
										<c:forEach items="${addProvinceList}" var="province">
											<option value="${province.provId }">${province.provName }</option>
										</c:forEach>
									</select>
								</div>
							</div>
							<div class="col-sm-10 col-sm-offset-2">
								<div class="panel-body">对应省份消费1元话费所赠送的游币数量</div>
							</div>
							<div class="form-group">
								<label for="exchangeChargeString" class="col-sm-2 control-label">兑换比例</label>
								<div class="col-sm-10">
										<input type="text" name="exchangeChargeString" placeholder="必须输入整数" class="form-control"/>
								</div>
							</div>
							<div class="form-group">
								<label for="exchangeStatusId" class="col-sm-2 control-label">状态</label>
								<div class="col-sm-10">
									<c:forEach items="${exchangeStatusList}" var="exchangeStatus">
										<input type="radio" name="exchangeStatusId" value="${exchangeStatus.id}" checked="checked"/>&nbsp;${exchangeStatus.status}
									</c:forEach>	
								</div>
							</div>
							<div class="form-group">
								<div class="col-sm-10 col-sm-offset-2">
										<input type="submit" class="btn btn-default" value="添加规则"/>
								</div>
							</div>
							
						</form>
					</div>
				</div>
			</div>
		</div>
		
		<div class="row">&nbsp;</div>
		<div class="row">
			<div class="col-xs-6 col-sm-11">
				<div class="table-responsive"
					style="vertical-align: middle;text-align: center;">
					<div class="panel-body">  消费金额是指对应省份消费1元话费所赠送的游币数量 </div>
					<table id="searchTable"
						class="table table-bordered table-hover table-condensed  ">
						<tr>
							<td><input type="checkbox" id="all" value="全选"
								 /> 全选</td>
							<td>省份代码</td>
							<td>省份</td>
							<td>兑换比例</td>
							<td>创建时间</td>
							<td>修改时间</td>
							<td>规则状态</td>
							<td>操作</td>
						</tr>
						<c:forEach items="${exchangeList}" var="exchange">
							<tr>
								<td><input type="checkbox"
									name="opt" value="${exchange.exchangeId}" />
								</td>
								<td>${exchange.exchangeProvId}</td>
								<td>${exchange.exchangeProv}</td>
								<td>${exchange.exchangeCharge}</td>
								<td>
									${exchange.exchangeCreateTime}
								</td>
								<td>
									${exchange.exchangeUpdateTime}
								</td>
								<td>
									${exchange.exchangeStatus}
								</td>
								<td>
									<a class="btn btn-info btn-sm" href="toUpdateExchangeJsp.do?exchangeId=${exchange.exchangeId}">
									<span class="glyphicon glyphicon-pencil"></span>修改</a>
								</td>
							</tr>
						</c:forEach>
						
					</table>
				</div>
			</div>
		</div>
		<div class="row">
			&nbsp;
			<a class="btn btn-primary" href="getAllExchangeByPage.do?nowPageString=${nowPage-1}">上一页</a>
			<a class="btn btn-primary" href="getAllExchangeByPage.do?nowPageString=${nowPage+1}">下一页</a>
		</div>
	</div>
	<c:if test="${msg!=null}">
  		<script type="text/javascript">
  			alert("${msg}");
  		</script>
  	</c:if>
  </body>
  	
</html>
